home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / utils / file / logiso.000 / logiso / Utils / logiso_preview < prev    next >
Encoding:
Korn shell script  |  1995-03-24  |  3.3 KB  |  125 lines

  1. #! /bin/ksh
  2. USAGE='USAGE: logiso_copy [ -d config_prefix ]
  3.    Get the iso log and install the logged files on the hard disk.
  4.  
  5. USAGE: logiso_preview  [ -d config_prefix ]
  6.    List the files that would have been installed by logiso_copy.
  7.  
  8. If -d is specified, then the config file, ${drive_or_mirror_prefix}config
  9. is used instead of config.  This allows a set of config files to be defined
  10. one for each unique combination of cd-rom mount point and mirror directory
  11. for users with multiple cd-rom drives or who what to populate different
  12. mirror directories, e.g. to mirror different cd-rom volumes.
  13. '
  14. # (C) Copyright 1995 by Michael Coulter.  All rights reserved.
  15.  
  16. # Process parameters
  17.  
  18.       COMMAND="$(basename "$0")"
  19.       CONFIG_PREFIX=""
  20.       if [ $# -eq 2 -a "$1" = "-d" ]
  21.       then
  22.          shift  # done with -d
  23.          CONFIG_PREFIX="$1"; shift
  24.       fi
  25.       if [ $# -ne 0 ]
  26.       then
  27.          echo "$USAGE" >&2
  28.          echo "Expected zero or 2 arguments, got $#" >&2
  29.          exit 1
  30.       fi
  31.  
  32. # Set variables
  33.  
  34.    ISOFS_UTIL_DIR="${ISOFS_UTIL_DIR:-/usr/src/linux/fs/isofs/Utils}"
  35.  
  36. # Source in user definitions
  37. # MOUNT_PATH
  38. # MAP_TO_PATH
  39. # CD_FILE
  40.  
  41.    CONFIG_FILE="${ISOFS_UTIL_DIR}/${CONFIG_PREFIX}config"
  42.    if [ ! -r "$CONFIG_FILE" ]
  43.    then
  44.       echo "Unable to find config file, $CONFIG_FILE" >&2
  45.       exit 1
  46.    fi
  47.    . "${ISOFS_UTIL_DIR}/${CONFIG_PREFIX}config"
  48.    export ISOFS_UTIL_DIR
  49.  
  50. # Set up temp files
  51.  
  52.     INODE_LIST="/tmp/logisoina$$"
  53.     INSTALL_LIST="/tmp/logisoinb$$"
  54.     trap "rm -f $INODE_LIST $INSTALL_LIST" 0 1 2 3 15
  55.  
  56. # Define standard functions
  57.  
  58.    . "$ISOFS_UTIL_DIR/ksh_fns"
  59.  
  60. # Check for root if doing copy
  61.  
  62.    if [ "$COMMAND" = "logiso_copy" ]
  63.    then
  64.       if [ "$(id -u)" -ne 0 ]
  65.       then
  66.      echo "$USAGE" >&2
  67.      echo "You are not root. Do you want to continue (type y for yes)?" >&2
  68.      read RESPONSE
  69.      if [ "$RESPONSE" != "y" ]
  70.      then
  71.         exit 1
  72.      fi
  73.       fi
  74.    fi
  75.  
  76.  
  77. # Do it
  78.  
  79.    logiso_get "$MOUNT_PATH" | cut -f1 | sort -n | uniq >  "$INODE_LIST"
  80.    rm -f "$ISOFS_UTIL_DIR/last_inodes"  2> /dev/null
  81.    cp "$INODE_LIST" "$ISOFS_UTIL_DIR/last_inodes"
  82.  
  83. # If CD_FILES does not exist, create it.
  84.  
  85.    USE_GZIP="FALSE"
  86.    if [ -f "${CD_FILES}.gz" -a ! -f "$CD_FILES" ]
  87.    then
  88.       USE_GZIP="TRUE"
  89.       echo "Uncompressing $CD_FILES"
  90.       gunzip < "${CD_FILES}.gz" > "$CD_FILES"
  91.    fi
  92.    if [ ! -f "$CD_FILES" ]
  93.    then
  94.       echo "$CD_FILES does not exist."
  95.       echo "Creating it will take a while."
  96.       find  "$MOUNT_PATH" 2> /dev/null | xargs ls -i -d 2> /dev/null     \
  97.      | sort -n > "$CD_FILES" 2> /dev/null
  98.       check_return 0 1 "Error making $CD_FILE"
  99.       echo "You should probably clear the log and try again." >&2
  100.       exit 1
  101.    fi
  102.  
  103. # Compare logged files against cd_files.
  104.  
  105.    echo "Comparing logged inodes against list in $CD_FILES"
  106.    process_lists "$INODE_LIST" "$CD_FILES" > "$INSTALL_LIST"
  107.  
  108.    if [ "$COMMAND" = "logiso_copy" ]
  109.    then
  110.       ##echo logiso_copy: do install
  111.       cp "$INSTALL_LIST" "$ISOFS_UTIL_DIR/last_install"
  112.       ## echo logiso_copy: install_list -d "$CONFIG_PREFIX" "$INSTALL_LIST" "$MOUNT_PATH" "$MAP_TO_PATH"
  113.       install_list -d "$CONFIG_PREFIX" "$INSTALL_LIST" "$MOUNT_PATH" "$MAP_TO_PATH"
  114.    else
  115.       ##echo logiso_copy: do preview
  116.       cat "$INSTALL_LIST"
  117.    fi   
  118.  
  119. # If we uncompressed the cd_files, file, remove the uncompressed copy.
  120.  
  121.    if [ "$USE_GZIP" = "TRUE" ]
  122.    then
  123.       rm -f "$CD_FILES"
  124.    fi
  125.